/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Models;

import Controllers.DBUtility;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Pan
 */
public class Prisoner {
    private int ID;
    private Criminal RelatedCriminal;
    private Date ImprisonDate;
    private Date ReleaseDate;
    private String PrisonName;
    private String CellNumber;
    private boolean IsReleased;
    private String ReleaseReason;

    public String getCellNumber() {
        return CellNumber;
    }

    public void setCellNumber(String CellNumber) {
        this.CellNumber = CellNumber;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public Date getImprisonDate() {
        return ImprisonDate;
    }

    public void setImprisonDate(Date ImprisonDate) {
        this.ImprisonDate = ImprisonDate;
    }

    public boolean isIsReleased() {
        return IsReleased;
    }

    public void setIsReleased(boolean IsReleased) {
        this.IsReleased = IsReleased;
    }

    public String getPrisonName() {
        return PrisonName;
    }

    public void setPrisonName(String PrisonName) {
        this.PrisonName = PrisonName;
    }

    public Criminal getRelatedCriminal() {
        return RelatedCriminal;
    }

    public void setRelatedCriminal(Criminal RelatedCriminal) {
        this.RelatedCriminal = RelatedCriminal;
    }

    public Date getReleaseDate() {
        return ReleaseDate;
    }

    public void setReleaseDate(Date ReleaseDate) {
        this.ReleaseDate = ReleaseDate;
    }

    public String getReleaseReason() {
        return ReleaseReason;
    }

    public void setReleaseReason(String ReleaseReason) {
        this.ReleaseReason = ReleaseReason;
    }

    public Prisoner() {
    }

    public Prisoner(int ID) {
        Connection conn = DBUtility.openConnection();
        try {
            CallableStatement cs = conn.prepareCall("{call sp_GetPrisonerByID(?)}");
            cs.setInt(1, ID);
            ResultSet rs = cs.executeQuery();
            if (rs.next()) {
                this.ID = rs.getInt("PrisonerID");
                RelatedCriminal = new Criminal(rs.getInt("CriminalID"));
                ImprisonDate = rs.getDate("ImprisonDate");
                ReleaseDate = rs.getDate("ReleaseDate");
                PrisonName = rs.getString("PrisonName");
                CellNumber = rs.getString("CellNumber");
                IsReleased = rs.getBoolean("IsReleased");
                ReleaseReason = rs.getString("ReleaseReason");
            }
            rs.close();
        } catch (SQLException ex) {
            Logger.getLogger(Prisoner.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
}
